package com.tensai.study.java.opensource.redis;

import cn.hutool.core.util.NumberUtil;
import org.junit.Test;

/**
 * Redis源码测试
 *
 * @author Tensai
 */
public class RedisTest {


	@Test
	public void test() {
		int key = 0B1101001001110001;
		int re = dictIntHashFunction(key);
		System.out.println(NumberUtil.getBinaryStr(re));
	}

	int dictIntHashFunction(int key) {
		key += ~(key << 15);
		key ^= (key >> 10);
		key += (key << 3);
		key ^= (key >> 6);
		key += ~(key << 11);
		key ^= (key >> 16);
		return key;
	}

	@Test
	public void fan() {
		int x = 2147483647;
		int y = ~x;
		System.out.println(NumberUtil.getBinaryStr(x));
		System.out.println(NumberUtil.getBinaryStr(y));
		int z = x + y;
		System.out.println(NumberUtil.getBinaryStr(z));
	}
}
